[?php use_stylesheets_for_form($form) ?]
[?php use_javascripts_for_form($form) ?]

[?php echo form_tag_for($form, '@<?php echo $this->params['route_prefix'] ?>') ?]
[?php include_partial('<?php echo $this->getModuleName() ?>/form_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?]
<div class="sf_admin_form">
    [?php echo $form->renderHiddenFields(false) ?]

    [?php if ($form->hasGlobalErrors()): ?]
    [?php echo $form->renderGlobalErrors() ?]
    [?php endif; ?]

    <div class="tabbable">
        <ul class="nav nav-tabs">
            [?php $flag = 0; ?]
            [?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?]
            [?php if ('NONE' != $fieldset): ?]
            <li class="[?php echo $flag == 0 ? 'active' : ''; ?]">
                <a href="#tab_[?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($fieldset)) ?]" data-toggle="tab">
                    [?php echo __($fieldset, array(), '<?php echo $this->getI18nCatalogue() ?>') ?]
                </a>
            </li>
            [?php $flag++; ?]
            [?php endif; ?]
            [?php endforeach; ?]
        </ul>
        <div class="tab-content">
            [?php $flag = 0; ?]
            [?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?]
            [?php include_partial('<?php echo $this->getModuleName() ?>/form_fieldset', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset, 'flag' => $flag)) ?]
            [?php $flag++; ?]
            [?php endforeach; ?]
        </div>
    </div>
</div>
[?php include_partial('<?php echo $this->getModuleName() ?>/form_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?]
</form>
